function selectUser(val){
		var url="getGrouphome.action?status="+val;
		openWindow(url,700,400);
	}

function setValue(value,val){
  var arr = eval(value);
  var names = "";
  var ids = "";
  for(i=0;i<arr.length;i++){
    ids =  ids + "," + arr[i].value;
    names = names + "," + arr[i].name;
  }
  if(names.length>0){
    names = names.substring(1);
    ids =  ids.substring(1);
  }
  document.getElementById(val+"names").value=names;
  document.getElementById(val+"ids").value=ids;
}

function getOldValue(val){
  var ids=document.getElementById(val+"ids").value;
  var names=document.getElementById(val+"names").value;
    var array="";
  if(ids!=''&&ids!='null'){
  var idarray=ids.split(",");
  var namearray=names.split(",");
  for(var i=0;i<idarray.length;i++){
  		if(i==0){
  			array+="{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
  		}else{
  	      array+=",{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
  	   } 
  }
  }
  return array;
}
	
function selectPeople(){
	var url="selectPoeple.action";
	openWindow(url,500,400);
}

function  setPeople(value){
if(value!=''&&value!='null'){
 var arr = eval(value);
 document.getElementById("cnames").value=arr.name;
 document.getElementById("cids").value=arr.value;
 }
}


function submitNext(){
	 var cids=$("#sids").val();
	 var report=$("#report").val();
	 if($.trim(cids)==''||$.trim(cids)=='null'){
		alert("办理人不能为空！");
		return;	
		}
	if($.trim(report)==''||$.trim(report)=='null'){
		alert("办理意见不能为空！");
		return;	
		}
		var table=$("#filetable").find("input[type=\"checkbox\"]");
		var fileId="";
		for(var i=0;i<table.length;i++){
			fileId+="_"+table[i].value;
		}
		$("#fileArray").val(fileId);
		var buttons=$("input[type='button']");
			for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=true;
			}
	$.post("subimtNext.action",$("form").serialize(),function(data){
			if(data=='success'){
				alert("操作成功！");
				window.close();
				var currentPage=$("#currentPage").val();
				window.opener.page(currentPage);
			}else{
				for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=false;
			}
				alert("操作失败！");
			}
		});	
}

function submitDaftNext(){
	 var cids=$("#sids").val();
	 var report=$("#report").val();
	 if($.trim(cids)==''||$.trim(cids)=='null'){
		alert("办理人不能为空！");
		return;	
		}
	if($.trim(report)==''||$.trim(report)=='null'){
		alert("办理意见不能为空！");
		return;	
		}
		var table=$("#filetable").find("input[type=\"checkbox\"]");
		var fileId="";
		for(var i=0;i<table.length;i++){
			fileId+="_"+table[i].value;
		}
		$("#fileArray").val(fileId);
		var buttons=$("input[type='button']");
			for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=true;
			}
	$.post("submitDaftNext.action",$("form").serialize(),function(data){
			if(data=='success'){
				alert("操作成功！");
				window.close();
				var currentPage=$("#currentPage").val();
				window.opener.page(currentPage);
			}else{
				for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=false;
			}
				alert("操作失败！");
			}
		});	
}


function completePolice(id,team){
		var report=$("#report").val();
		var table=$("#filetable").find("input[type=\"checkbox\"]");
		var fileId="";
		for(var i=0;i<table.length;i++){
			fileId+="_"+table[i].value;
		}
		var buttons=$("input[type='button']");
			for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=true;
			}
	var param={"policeId":id,"content":report,"policeTeam.fileId":fileId,'team.id':team};
	$.post("completeTeam.action",param,function(data){
			if(data=='success'){
				alert("操作成功！");
				window.close();
				var currentPage=$("#currentPage").val();
				window.opener.page(currentPage);
			}else{
			for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=false;
			}
				alert("操作失败！");
			}
		});	
}

function completeAllPolice(police,id){
	var param={"team.id":id,"policeId":police};
	if(confirm("确定要结束？")){
	var buttons=$("input[type='button']");
			for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=true;
			}
		$.post("draftAllComplete.action",param,function(data){
			if(data=='success'){
				alert("操作成功！");
				window.close();
				var currentPage=$("#currentPage").val();
				window.opener.page(currentPage);
			}else{
			for(var i=0;i<buttons.length;i++){
				buttons[i].disabled=false;
			}
				alert("操作失败！");
			}
		});
	}
}